package com.atguigu.springboot.config;

import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.client.ClientConfiguration;
import org.springframework.data.elasticsearch.client.RestClients;
import org.springframework.data.elasticsearch.config.AbstractElasticsearchConfiguration;
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;

/**
 * @author : wenchao.long
 * @date : Created in 2020/12/02 10:25 周三
 * @description :
 *         <p>
 *         SpringBoot2.x版本引入SpringDataElasticSearch
 *         使用配置类的方式
 *         </p>
 */
@Configuration
@EnableElasticsearchRepositories
public class RestClientConfig extends AbstractElasticsearchConfiguration {

    @Override
    public RestHighLevelClient elasticsearchClient() {
        ClientConfiguration clientConfiguration = ClientConfiguration.builder()
                .connectedTo("123.56.83.118:9200")
                .build();
        return RestClients.create(clientConfiguration).rest();
    }
}
